package com.example.fist.personRepository;


import com.example.fist.entity.AdminEntity;
import com.example.fist.entity.CodeEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;


public interface AdminJpaRepository extends JpaRepository<AdminEntity, Integer> {

    @Query(nativeQuery = true, value = "SELECT * FROM admin WHERE name = :name and pass=:pass ")
    AdminEntity Login(@Param("name") String name, @Param("pass") String pass) ;


    @Query(nativeQuery = true, value = "SELECT * FROM admin WHERE name = :name ")
    AdminEntity getAdmin(@Param("name") String name) ;

    @Transactional
    @Modifying
    @Query(nativeQuery = true, value = "UPDATE admin SET pass =:pass WHERE ad_id =:ad_id ")
    int changPass(@Param("ad_id") int ad_id,@Param("pass") String pass) ;

}
